package com.cuit.riskassessment.service.impl;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cuit.riskassessment.dao.ra.RaMapper;
import com.cuit.riskassessment.service.RaService;
import com.cuit.riskassessment.vo.RaParam;
@Service(value="raService")
public class RaServiceImpl implements RaService{

	@Autowired
	@Resource(name="raMapper")
	private RaMapper raMpper;
	
	@Override
	public boolean isExist(int projid) {
		// TODO Auto-generated method stub
		
		return this.raMpper.isExist(projid)<=0?false:true;
	}

	@Override
	public boolean addRa(RaParam ra) {
		// TODO Auto-generated method stub
		return this.raMpper.addRa(ra)<=0?false:true;
	}

	@Override
	public boolean updateRa(RaParam ra) {
		// TODO Auto-generated method stub
		return  this.raMpper.updateRa(ra)<=0?false:true;
	}

	@Override
	public boolean updateORInsert(RaParam ra) {
		// TODO Auto-generated method stub
		boolean flag =  false;
		if(ra.getId()!=null)
		{
			flag = this.updateRa(ra);
		}else
		{
			Integer id = this.raMpper.getMaxId();
			id= (id==null)?2:id+2;
			ra.setId(id);
			flag = this.addRa(ra);
		}
		return flag;
	}

	@Override
	public RaParam getRaVo(Integer projid) {
		// TODO Auto-generated method stub
		return this.raMpper.getRa(projid);
	}

	
	
}
